package com.bestv.search.common.dao.hibernate;

import com.bestv.search.common.dao.HistoryDao;
import com.bestv.search.common.model.History;

import java.util.List;

/**
 * @author Michael Wang
 */

// $Id$
public class HistoryDaoHibernate extends GenericDaoHibernate<History, Long> implements HistoryDao {

    public HistoryDaoHibernate() {
        super(History.class);
    }

    public void saveHistoryList(List<History> historyList) {
        getHibernateTemplate().saveOrUpdateAll(historyList);
    }

    @SuppressWarnings("unchecked")
    public History getHistoryByUserId(String userId) {
        List<History> list = getHibernateTemplate().find("from History where userId = ?", userId);
        if (list == null || list.size() == 0)
            return null;
        return list.get(0);
    }
}
